﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace IMDemo.TemplateSelectors
{
    public class DialogTypeTemplateSelector : StyleSelector
    {
        public Style PrivateItemStyle { get; set; }

        public Style GroupItemStyle { get; set; }

        public override Style SelectStyle(object item, DependencyObject container)
        {
            Type t = item.GetType();
            int type = 0;
            PropertyInfo[] properties = t.GetProperties();
            foreach (PropertyInfo pi in properties)
            {
                if (pi.Name == "DialogType")
                {
                    type = (int)pi.GetValue(item, null);
                    break;
                }
            }

            if (type == 0)
            {
                return this.PrivateItemStyle;
            }

            if (type == 1)
            {
                return this.GroupItemStyle;
            }

            return null;
        }
    }
}
